﻿using LibBinary.DataSource;
using LibBinary.FileData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LibBinary.FileDeclaration.Binary
{
    public class FieldDeclaration : IFileDeclaration
    {
        public string FieldName { get; private set; }

        private readonly IFileDeclaration value;
        private readonly IFieldArrangement arrangement;

        public FieldDeclaration(string name, IFieldArrangement arrangement, IFileDeclaration value)
        {
            this.FieldName = name;
            this.value = value;
            this.arrangement = arrangement;
        }

        public AbstractFileData Read(BinaryFileSource src, AbstractFileData parentNode)
        {
            return arrangement.Read(src, parentNode, FieldName, value);
        }

        public void Write(BinaryFileSource src, AbstractFileData data)
        {
            arrangement.Write(src, data, FieldName, value);
        }
    }
}
